<template>
  <div id="commit">
          <div>一些评论们。。</div>
          <div v-for="commitlist in commitlists ">
              <img :src="commitlist.commit.avatar_url" width="80" height="80" :alt="commitlist.commit.login">
          <div>
              <b>{{commitlist.commit.login}}</b>
              评论于{{commitlist.commit.commit_at}}
          </div>
          <p>
              {{commitlist.commit.body}}
          </p>
          </div>
          <p>
            评论施工中。。。如果想要评论，请到<a :href="issueurl">这里</a>评论
          </p>
  </div>
</template>

<script>
import marked from "marked";
export default {
  data() {
    return {
      commitlists: [],
      issueurl:""
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init: function() {
      var that = this;
      this.issueurl = "https://github.com/FireUnicornser/govBlog/issues/"+that.$route.params.id
      this.$http({
        method: "get",
        url:
          "https://api.github.com/repos/FireUnicornser/govBlog/issues/" +
          that.$route.params.id +
          "/comments"
      }).then(function(response) {
          for (var i = 0; i < response.data.length; i++) {
            that.commitlists.push({
              commit: {
                avatar_url: response.data[i]["user"]["avatar_url"],
                login: response.data[i]["user"]["login"],
                commit_at: response.data[i]["created_at"],
                body: response.data[i]["body"]
              }
            });
          }
      });
    }
  }
};
</script>

<style>

</style>
